<template>
  <div>
    <el-form :model="manager" ref="numberValidateForm" label-width="100px" class="demo-ruleForm">
      <el-form-item
        label="管理员名称"
        prop="managerName">
        <el-input type="" v-model="manager.managerName" class="loginInput"></el-input>
      </el-form-item>
      <el-form-item
        label="管理员密码"
        prop="managerPassword">
        <el-input type="password" v-model="manager.managerPassword" class="loginInput"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="login">登录</el-button>
        <el-button @click="resetForm">重置</el-button>
      </el-form-item>
    </el-form>
  </div>
<!--  <div>-->
<!--    用户名: <label>-->
<!--    <input type="text" v-model="manager.managerName" aria-placeholder="请输入用户名！"/>-->
<!--  </label>-->
<!--    <br>-->
<!--    密码: <label>-->
<!--    <input type="text" v-model="manager.managerPassword" aria-placeholder="请输入用户名！"/>-->
<!--  </label>-->
<!--    <br>-->
<!--    <button v-on:click="login">登录</button>-->
<!--  </div>-->
</template>

<script>
export default {
  name: 'Login',
  data () {
    return {
      msg: '',
      manager: {
        managerName: 'lbb123',
        managerPassword: '123456'
      }

    }
  },
  methods: {
    resetForm () {
      this.manager = []
    },
    login () {
      this.axios.post('http://localhost:8989/login', this.manager).then(res => {
        this.msg = res.data.msg
        console.log(this.msg)
        alert(this.msg)
        if (this.msg === '登录成功!') {
          this.$router.push('/index')
        } else {
          this.$router.push('/login')
        }
      })
    }
  }
}
</script>

<style scoped>
.loginInput{
  width: 100%
}
.demo-ruleForm{
  text-align: center;
  margin-left: 30%
}

</style>
